<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

    </style>
</head>
<body>
    <input type="button" id="btn1" value="打开">
    <input type="button" id="btn2" value="关闭">
</body>
<script>
    // - 窗口操作
    //     - open()
    //     - close()

    // 配合css属性使用

    var btn1 = document.getElementById("btn1");
    var btn2 = document.getElementById("btn2");

    // 事件处理函数：事件源.on事件类型=function(){}
    btn1.onclick = function(){
        open("http://www.baidu.com");
    }
    btn2.onclick = function(){
        if(confirm("真的要关闭当前页面吗？")){
            close();
        }
    }
</script>
</html>